#
# from selenium import webdriver
# import time
#
# driver = webdriver.Firefox()
# driver.get('http://localhost/test/fileupload.html')
# upload = driver.find_element_by_id('file')
# time.sleep(12)
# upload.send_keys('d:\\all_money.wmv','d:\\download_file.html')  # send_keys
# print (upload.get_attribute('value'))  # check value
#
# driver.quit()

# -*- coding: utf-8 -*-
# from selenium import webdriver
# import win32gui
# import win32con
# import time
#
# dr = webdriver.Firefox()
# dr.get('http://localhost/test/fileupload.html')
# upload = dr.find_element_by_id('file')
# upload.click()
# time.sleep(1)
#
# # win32gui
# dialog = win32gui.FindWindow('#32770', '文件上传')  # 对话框
# ComboBoxEx32 = win32gui.FindWindowEx(dialog, 0, 'ComboBoxEx32', None)
# ComboBox = win32gui.FindWindowEx(ComboBoxEx32, 0, 'ComboBox', None)
# Edit = win32gui.FindWindowEx(ComboBox, 0, 'Edit', None)  # 上面三句依次寻找对象，直到找到输入框Edit对象的句柄
# button = win32gui.FindWindowEx(dialog, 0, 'Button', None)  # 确定按钮Button
#
# win32gui.SendMessage(Edit, win32con.WM_SETTEXT, None, 'd:\\all_money.wmv')  # 往输入框输入绝对地址
# win32gui.SendMessage(dialog, win32con.WM_COMMAND, 1, button)  # 按button
#
# print (upload.get_attribute('value'))
# dr.quit()

# -*- coding: utf-8 -*-
from selenium import webdriver
import os
import time

driver = webdriver.Firefox()
driver.get('http://localhost/test/fileupload.html')
driver.find_element_by_id('file').click()
time.sleep(1)

os.system('D:\\Python\\Demo\\uploadfile.exe "d:\\all_money.wmv" "d:\\test.txt"')  # 这里可以对传参进行参数化，我们可以通过py脚本来控制所要上传的文件了

time.sleep(3)
driver.quit()
